package org.shopen.ai.puremvc.model.settings
{
	import mx.collections.ArrayCollection;
	
	public class CommitSettingsResult implements ICommitSettingsResult
	{
		protected var _errors : ArrayCollection = new ArrayCollection();
		public function get errors():ArrayCollection
		{
			return _errors;
		}
		
		public function get isValid():Boolean
		{
			var result : Boolean = false;
			if (errors == null)
			{
				result = true;
			}
			else
			{
				result = errors.length == 0;
			}
			return result;
		}
		
		public function CommitSettingsResult(errors : ArrayCollection = null)
		{
			this._errors = errors;
		}

		public function toString():String
		{
			var result : String = "";
			if (isValid)
			{
				result += "Settings are valid.";
			}
			else
			{
				result += "Check following settings:\n";
				result += errors.toArray().join("\n");
			}
			return result;
		}
	}
}